package com.zephyr.vchcenter.bpm.decision;

import org.apache.log4j.Logger;

import com.hiaward.bpm.context.ServiceContext;
import com.hiaward.bpm.exception.ParameterException;
import com.hiaward.bpm.exception.RuleException;
import com.hiaward.bpm.exception.ServiceException;
import com.hiaward.bpm.rule.Decision;
import com.zephyr.vchcenter.bean.Voucher;
import com.zephyr.vchcenter.bpm.action.CreateVoucherAction;
import com.zephyr.vchcenter.dao.IBaseDao;
import com.zephyr.vchcenter.helper.SpringHelper;

public class AuditTypeDecisionHandler extends Decision {
	private final Logger log=Logger.getLogger(AuditTypeDecisionHandler.class);
	@Override
	public void exceptionHandle(ServiceContext arg0) {
		

	}

	@Override
	public String make(ServiceContext arg0) throws RuleException,
			ServiceException, ParameterException {
		log.debug("进入AuditTypeDecisionHandler...................");
		String vchsid=(String)arg0.getInputParameterValue("vchsid");
		IBaseDao dao = (IBaseDao) SpringHelper.getBean("baseDao");
		Voucher voucher=(Voucher)dao.findById("Voucher",vchsid);
		String acctype=voucher.getAcctype();
		String transition=null;
		if("2".equals(acctype)){
			log.debug("转向财政户审票");
			voucher.setChkstate("5");
			dao.saveOrUpdate(voucher);
			transition="to financialAudit";
		}else{
			log.debug("转向非财政户审票");
			transition="to audit";
		}
		//String transition="2".equals(acctype)?"to financialAudit":"to audit";
		log.debug(acctype+"----------->");
		log.debug("离开AuditTypeDecisionHandler...................");
		return transition;
	}

}
